﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Agr.CQRS.Domain.Commands;

namespace Tests.Agr.CQRS.Domain.Commands
{
    [TestClass]
    public class When_Base_CommandHandler_Is_Called_With_Command
    {
        private commandHandlerImpl commandHandler;
        private commandImpl command;
        
        [TestInitialize]
        public void TestInitialize()
        {
            //Given
            commandHandler = new commandHandlerImpl();
            command = new commandImpl();

            //When
            ((CommandHandler)commandHandler).ExecuteCommand(command);
        }


        [TestMethod()]
        public void Then_The_Command_Is_Cast_To_The_Actual_Class()
        {
            Assert.AreEqual(command, commandHandler.LastCommand);
        }


        private class commandImpl : Command
        {
        }
        private class commandHandlerImpl : CommandHandler<commandImpl>
        {
            public commandImpl LastCommand { get; set; }
            protected override void ExecuteInternal(commandImpl command)
            {
                LastCommand = command;
            }
        }

    }
}
